﻿namespace Microsoft.VisualStudio.Labs
{
    using Microsoft.VisualStudio.Language.Intellisense;
    using System;
    using System.Windows.Media;

    public class GlyphService : BitmapStripImageList, IGlyphService
    {
        private static GlyphService _instance;
        private const int PixelHeightPerItem = 0x10;
        private const int PixelWidthPerItem = 0x10;
        private GlyphService()
            : base("pack://application:,,,/VSIXUtilities;component/Resources/ImageStrip.png", 0x10, 0x10)
        {
        }

        public ImageSource GetGlyph(StandardGlyphGroup group, StandardGlyphItem item)
        {
            if (group >= StandardGlyphGroup.GlyphGroupUnknown)
            {
                return null;
            }
			//The following line was modified by Abdulhamed
			int index = (group < StandardGlyphGroup.GlyphGroupError) ? ((int)(group + (((int)item)))) : ((int)group);
            return this.TryGetImage(index);
        }

        public static GlyphService GetService()
        {
            if (_instance == null)
            {
                _instance = new GlyphService();
            }
            return _instance;
        }
    }
}

